<template>
	<!-- 巡检任务 执行 与 回执  -->
	<div>
		<div id="app" class="container">
		  <!--查询模块-->
		<div class="row" >
		  <div class="col-12 text-right">
		    <form class="form-group form-inline justify-content-end">
			<div class="row mb-12">
			  <div class="col-md-4">
			    <span>任务编号</span>
			    <input class="form-control" type="search" v-model="psInspectiontaskMain.inspectiontaskcode" placeholder="请输入查询字符">
			  </div>
			  <div class="col-md-4">
			    <span>线路编号</span>
			    <input class="form-control" type="search" v-model="psInspectiontaskMain.linecode" placeholder="">
			  </div>
			  <div class="col-md-4">
			    <span>任务状态</span>
			    <select class="form-control" v-model="psInspectiontaskMain.taskstatus">
			      <option value="-1" selected>--请选择--</option>
			      <option v-for="item in psSystemconfig" :value="item.configvalueid" :key="item.id"   >{{ item.configvaluename }}</option>
			    </select>
			  </div>
			  <div class="col-md-4">
			    <span>发现人</span>
			    <input class="form-control" type="search" v-model="psInspectiontaskMain.createdby" placeholder="">
			  </div>
			  <div class="col-md-4">
			    <span>下发人</span>
			    <input class="form-control" type="search" v-model="psInspectiontaskMain.issuedbyname" placeholder="">
			  </div>
			  <div class="col-md-4">
			    <span>下发时间</span>
			    <input class="form-control" type="datetime-local" v-model="psInspectiontaskMain.issuedtime" placeholder="">
			  </div>
			</div>

			
		    <button class="btn btn-outline-success " @click.prevent="load()">查询</button>
		    </form>
	
		  </div>
		</div>  <!--查询模块结束-->
		        <table  class="table table-striped table-hover table-bordered">
		            <thead>
						<tr>
						               <td v-text="'巡检任务编号'"></td>
						               <td v-text="'巡检任务名称'"></td>
						               <td v-text="'所属线路'"></td>
						               <td v-text="'起始杆号'"></td>
						               <td v-text="'终止杆号'"></td>
						               <td v-text="'下发人'"></td>
						               <td v-text="'任务下发时间'"></td>
						               <td v-text="'任务状态'"></td>
						               <td v-text="'任务完成时间'"></td>
									   <td>操作</td>
						 </tr>
					</thead>
		            <tbody>
						<tr   v-for="o in list" >
						               <td v-text="o.inspectiontaskcode"></td>
						               <td v-text="o.inspectiontaskname"></td>
						               <td v-text="o.linename"></td>
						               <td v-text="o.startpolecode"></td>
						               <td v-text="o.endpolecode"></td>
						               <td v-text="o.issuedbyname"></td>
						               <td v-text="o.issuedtime"></td>
						               <td :style="{color: o.taskstatus === 1 ? 'goldenrod' : (o.taskstatus === 2 ? 'royalblue' : (o.taskstatus === 3 ? 'red' : (o.taskstatus === 4 ? 'green' : '')))}" v-text="o.taskstatusname"></td>
						               <td v-text="o.finishtime"></td>
									   <td>
										   <div v-if="o.iscancel!=0">
											   <button type="button" v-if="o.taskstatus==1 || o.taskstatus==2 || o.taskstatus==3 || o.taskstatus==4" @click="$router.push({ path: '/InfoInspection', query: { ps_Id: o.ps_Id } })" class="btn btn-outline-primary" >查看</button>
											   										  
										   </div>
										   <div v-else>
											   <button type="button" v-if="o.taskstatus == 1 || o.taskstatus == 2 || o.taskstatus == 3 || o.taskstatus == 4" @click="$router.push({ path: '/InfoInspection', query: { ps_Id: o.ps_Id } })" class="btn btn-outline-primary">查看</button>
											   <button type="button" v-if="o.taskstatus==1 || o.taskstatus==3" @click="$router.push({ path: '/ReceiptEntry', query: { lineid: o.lineid,linename:o.linename,inspectiontaskcode:o.inspectiontaskcode,taskstatus:o.taskstatus,ps_Id:o.ps_Id } })" class="btn btn-outline-primary" >回执录入</button>
											   <button type="button" v-if="o.taskstatus==1 || o.taskstatus==2" class="btn btn-outline-primary" @click="executeUpdate(o)">执行</button>
											   
										   </div>
										   
									   </td>
						</tr>
					</tbody>
		        </table>
				
		         <!--分页-->
		        <!--显示分页信息-->
		        <div class="row  text-right">
		            <!--文字信息-->
		            <div class="col-md-6">
		                当前第 <input name="startPage"  :value="pageInfo.pageNum"  style="width: 20px"/>/{{pageInfo.pages}}页.一共 {{pageInfo.total}}条记录
		            </div>
		            <!--点击分页-->
		            <div class="col-md-6">
		                <nav aria-label="Page navigation example">
		                    <ul class="pagination">
		                        <li class="page-item"><a class="page-link" href="javascript:;" @click="pageInfo.pageNum=1;load( )">首页</a></li>
		                        <li class="page-item" :class="{'disabled':!pageInfo.hasPreviousPage}">
		                            <a class="page-link" href="javascript:;" @click="pageInfo.pageNum=pageInfo.pageNum-1;load()" aria-label="Previous">
		                                <span aria-hidden="true">&laquo;</span>
		                            </a>
		                        </li>
		                        <li class="page-item" v-for="p in pageInfo.navigatepageNums" :class="{'active':pageInfo.pageNum==p}"><a class="page-link"  href="javascript:;" @click="pageInfo.pageNum=p;load()" v-text="p"></a></li>
		                        <li class="page-item" :class="{'disabled':!pageInfo.hasNextPage}">
		                            <a class="page-link" href="javascript:;"  @click="pageInfo.pageNum=pageInfo.pageNum-0+1;load()" aria-label="Next">
		                                <span aria-hidden="true">&raquo;</span>
		                            </a>
		                        </li>
		                        <li class="page-item"><a class="page-link"  href="javascript:;" @click="pageInfo.pageNum=pageInfo.pages;load()">尾页</a></li>
		                    </ul>
		                </nav>
		            </div>
		        </div>
		        <!--分页结束-->
		</div>
	</div>
</template>

<script>
	import {psInspectiontaskMainTwo,queryByIsCancel,updatePsInspectiontaskMain} from '../../config/request.js' 
	export default {
		data(){
		    return  {
		       psInspectiontaskMain:{
		       taskstatus:'-1',
		       pageNum:'1',
		       pageSize:'5' 
		    },
		       list:[],
		       pageInfo:{},
			psSystemconfig:{},
			updateObj:{} // 修改对象,
		}
	},methods:{
	    load(){
	        this.psInspectiontaskMain.pageNum=this.pageInfo.pageNum;
				psInspectiontaskMainTwo(this.psInspectiontaskMain).then(json=>{
					this.pageInfo=json.data.pageInfo;
					this.list=json.data.pageInfo.list;
				});
				queryByIsCancel().then(json=>{
					this.psSystemconfig=json.data.queryIsCancel
				})	
	    },
		// 修改 任务状态
		executeUpdate(o){
			let flag = confirm("确定要修改？");
			if(flag){/* 
				this.updateObj.ps_Id=ps_Id
				this.updateObj.taskstatus=3
				this.updateObj.taskstatusname="执行中" */
				
						o.taskstatus = 3
						o.taskstatusname = '执行中'
				updatePsInspectiontaskMain(o).then(json=>{
					alert(json.message)
				})
			}
		}
		
	},mounted(){
	    this.load();
	}
}
</script>

<style>
</style>